home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / EmacsTeX / Emacs-3.0.1 / Source / PrefControl.m < prev   
Encoding:
Text File  |  1995-06-12  |  3.4 KB  |  154 lines

  1. /* The PrefControl implementation for Emacs.
  2.  
  3.    For legal stuff see the file COPYRIGHT.  */
  4.  
  5. #import <defaults/defaults.h>
  6.  
  7. #import "PrefControl.h"
  8. #import "EmacsApp.h"
  9. #import "EtermView.h"
  10. #import "defaults.h"
  11.  
  12. @implementation PrefControl
  13.  
  14. -windowDidBecomeKey: sender
  15. {
  16.   const char *value;
  17.  
  18.   [autoLaunchSwitch setIntValue:
  19.    strcmp (NXGetDefaultValue ([NXApp appName],
  20.                   "HideOnAutoLaunch"), "YES") ? 0 : 1];
  21.  
  22.   value = NXGetDefaultValue ("Workspace", "DefaultOpenApp");
  23.   [defaultAppSwitch setIntValue:
  24.    (value && !strcmp (value, "Emacs.app")) ? 1 : 0];
  25.  
  26.   [spaceSlider setFloatValue: [[NXApp currentView] spacing]];
  27.  
  28.   [emacsPathField setStringValue: NXGetDefaultValue ([NXApp appName], "EmacsPath")];
  29.   [lispPathField setStringValue: NXGetDefaultValue ([NXApp appName], "LispPath")];
  30.   return self;
  31. } /* -windowDidBecomeKey */
  32.  
  33. -autoLaunch: sender
  34. {
  35.   NXWriteDefault ([NXApp appName], "HideOnAutoLaunch",
  36.           [sender intValue] ? "YES" : "NO");
  37.   return self;
  38. } /* -autoLaunch: */
  39.  
  40. -defaultApp: sender
  41. {
  42.   if ([sender intValue])
  43.     {
  44.       NXWriteDefault ("Workspace", "DefaultOpenApp", "Emacs.app");
  45.     }
  46.   else
  47.     {
  48.       NXRemoveDefault ("Workspace", "DefaultOpenApp");
  49.     }
  50.   return self;
  51. } /* -defaultApp: */
  52.  
  53. -spaceChanged: sender
  54. {
  55.   [[NXApp currentView] setSpacing: [sender floatValue]];
  56.   return self;
  57. } /* -spaceChanged */
  58.  
  59. -emacsPathChanged: sender
  60. {
  61.   [self setEmacsPath: [sender stringValue]];
  62.   return self;
  63. } /* -emacsPathChanged: */
  64.  
  65. -lispPathChanged: sender
  66. {
  67.   [self setLispPath: [sender stringValue]];
  68.   return self;
  69. } /* -lispPathChanged: */
  70.  
  71. -selectEmacsPath: sender
  72. {
  73.   char *path;
  74.   const char *directory;
  75.   const char *const *fileNames;
  76.  
  77.   if (!openPanel)
  78.     openPanel = [OpenPanel new];
  79.   [openPanel allowMultipleFiles: NO];
  80.   [openPanel chooseDirectories: NO];
  81.   if ([openPanel runModal])
  82.     {
  83.       directory = [openPanel directory];
  84.       fileNames = [openPanel filenames];
  85.       if (fileNames)
  86.     {
  87.       path = malloc (2 + strlen (directory) + strlen (*fileNames));
  88.       strcat (strcat (strcpy (path, directory), "/"), *fileNames);
  89.         [self setEmacsPath: path];
  90.       free (path);
  91.     }
  92.     }
  93.   return self;
  94. } /* selectEmacsPath: */
  95.  
  96. -selectLispPath: sender
  97. {
  98.   char *path;
  99.   const char *directory;
  100.   const char *const *fileNames;
  101.   static const char *const types[] =
  102.     {
  103.       "el",
  104.       "elc",
  105.       NULL,
  106.     };
  107.  
  108.   if (!openPanel)
  109.     openPanel = [OpenPanel new];
  110.   [openPanel allowMultipleFiles: NO];
  111.   [openPanel chooseDirectories: NO];
  112.   if ([openPanel runModalForTypes: types])
  113.     {
  114.       directory = [openPanel directory];
  115.       fileNames = [openPanel filenames];
  116.       if (fileNames)
  117.     {
  118.       path = malloc (2 + strlen (directory) + strlen (*fileNames));
  119.       strcat (strcat (strcpy (path, directory), "/"), *fileNames);
  120.         [self setLispPath: path];
  121.       free (path);
  122.     }
  123.     }
  124.   return self;
  125. } /* selectLispPath: */
  126.  
  127. -defaultEmacsPath: sender
  128. {
  129.   [self setEmacsPath: DEFAULT_EMACS_PATH];
  130.   return self;
  131. } /* defaultEmacsPath: */
  132.  
  133. -defaultLispPath: sender
  134. {
  135.   [self setLispPath: DEFAULT_LISP_PATH];
  136.   return self;
  137. } /* defaultLispPath: */
  138.  
  139. -setEmacsPath: (const char *) path;
  140. {
  141.   [emacsPathField setStringValue: path];
  142.   NXWriteDefault ([NXApp appName], "EmacsPath", path);
  143.   return self;
  144. } /* setEmacsPath: */
  145.  
  146. -setLispPath: (const char *) path;
  147. {
  148.   [lispPathField setStringValue: path];
  149.   NXWriteDefault ([NXApp appName], "LispPath", path);
  150.   return self;
  151. } /* setLispPath: */
  152.  
  153. @end
  154.